require.sync("CheckStatausEnum")
Ext.define('App.controller.customerClubApply.CustomerClubApplyViewController', {
	extend : 'Ext.app.ViewController',
	alias : 'controller.customerClubApplyViewController',
	menu : Ext.widget('menu'),
	control : {
		'customerClubApplyView customerClubApplyList' : {
			beforerender : function(grid) {
				var buttons = {
					'bs/customerClubApply/saveCustomerClubApply' : function(permit) {
						BaseUtil.createView('customerClubApply.CustomerClubApplyWindow',permit,{storeId:'customerClubApply.CustomerClubApplyStore'}).show();
					}
				};
				BaseUtil.createPermitTbar(grid, buttons);
			},
			itemcontextmenu : function(view, record, item, index, e) {
				var id = record.get('id');
				var menuitems = [];
				var checkStatus = record.get("checkStatus");
				if(checkStatus==CheckStatausEnum.WAIT.getValue()){
                    menuitems['bs/customerClubApply/checkCustomerApply']=function(permit) {

                        var win = BaseUtil.createView('customerClubApply.CustomerClubApplyWindow',permit,{storeId:'customerClubApply.CustomerClubApplyStore'});
                        win.down('form').loadRecord(record);
                        // win.down("box").getEl().dom.src =  basePath + "/file/display/" + record.get("certificateUrl");
                        win.show();
                        Ext.getCmp("imagebox").getEl().dom.src=basePath + "/file/display/" + record.get("certificateUrl");
                        Ext.getCmp("carSideUrl").getEl().dom.src=basePath + "/file/display/" + record.get("carSideUrl");
                        Ext.getCmp("carPositiveUrl").getEl().dom.src=basePath + "/file/display/" + record.get("carPositiveUrl");

                        Ext.getCmp("drivesecondUrl").getEl().dom.src=basePath + "/file/display/" + record.get("drivesecondUrl");
                        Ext.getCmp("driveinnerUrl").getEl().dom.src=basePath + "/file/display/" + record.get("driveinnerUrl");
                        Ext.getCmp("secondUrl").getEl().dom.src=basePath + "/file/display/" + record.get("secondUrl");

                        Ext.getCmp("innerUrl").getEl().dom.src=basePath + "/file/display/" + record.get("innerUrl");
                        Ext.getCmp("sideUrl").getEl().dom.src=basePath + "/file/display/" + record.get("sideUrl");
                        Ext.getCmp("rightUrl").getEl().dom.src=basePath + "/file/display/" + record.get("rightUrl");

                        Ext.getCmp("leftUrl").getEl().dom.src=basePath + "/file/display/" + record.get("leftUrl");
                        Ext.getCmp("rightUrl").getEl().dom.src=basePath + "/file/display/" + record.get("rightUrl");

                        // win.down("box").getEl().dom.src =  basePath + "/file/display/" + record.get("certificateUrl");
                    }
                }
                    menuitems['bs/customerClubApply/view']=function(permit) {

                        var win = BaseUtil.createView('customerClubApply.CustomerClubApplyViewWindow',permit,{storeId:'customerClubApply.CustomerClubApplyStore'});
                        win.down('form').loadRecord(record);
                        // win.down("box").getEl().dom.src =  basePath + "/file/display/" + record.get("certificateUrl");
                        win.show();
                        Ext.getCmp("imagebox").getEl().dom.src=basePath + "/file/display/" + record.get("certificateUrl");
                        Ext.getCmp("carSideUrl").getEl().dom.src=basePath + "/file/display/" + record.get("carSideUrl");
                        Ext.getCmp("carPositiveUrl").getEl().dom.src=basePath + "/file/display/" + record.get("carPositiveUrl");

                        Ext.getCmp("drivesecondUrl").getEl().dom.src=basePath + "/file/display/" + record.get("drivesecondUrl");
                        Ext.getCmp("driveinnerUrl").getEl().dom.src=basePath + "/file/display/" + record.get("driveinnerUrl");
                        Ext.getCmp("secondUrl").getEl().dom.src=basePath + "/file/display/" + record.get("secondUrl");

                        Ext.getCmp("innerUrl").getEl().dom.src=basePath + "/file/display/" + record.get("innerUrl");
                        Ext.getCmp("sideUrl").getEl().dom.src=basePath + "/file/display/" + record.get("sideUrl");
                        Ext.getCmp("rightUrl").getEl().dom.src=basePath + "/file/display/" + record.get("rightUrl");

                        Ext.getCmp("leftUrl").getEl().dom.src=basePath + "/file/display/" + record.get("leftUrl");
                        Ext.getCmp("rightUrl").getEl().dom.src=basePath + "/file/display/" + record.get("rightUrl");

                        // win.down("box").getEl().dom.src =  basePath + "/file/display/" + record.get("certificateUrl");
                    }




				var status = record.get('status'),store = Ext.StoreMgr.get('customerClubApply.CustomerClubApplyStore');
				if(status === StatusEnum.DELETE.getValue()){
					menuitems['bs/customerClubApply/recover'] = function(permit) {
						BaseUtil.statusConfirm('确认恢复此记录吗?',permit.url,id,store);
					}
				}else{
					menuitems['bs/customerClubApply/removeCustomerClubApply'] = function(permit) {
						BaseUtil.statusConfirm('确认删除此记录吗?',permit.url,id,store);
					}
				}
				BaseUtil.createPermitMenu(view, this.menu, e, menuitems);
			},
			render : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('customerClubApply.CustomerClubApplyStore'),Ext.getCmp('customerClubApplyView').down('customerClubApplySearch form').getForm().getFieldValues());
			}
		},
		'customerClubApplyView customerClubApplySearch [action=search] ' : {
			click : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('customerClubApply.CustomerClubApplyStore'),Ext.getCmp('customerClubApplyView').down('customerClubApplySearch form').getForm().getFieldValues());
			}
		}
	}
});